package com.lagou.v4.container;


import com.lagou.servlet.HttpServlet;
import com.lagou.v4.LifeCycle;

import java.net.URLClassLoader;

/**
 * @author Kirito
 * @description:
 * @date 2020/05/02
 */
public class Wrapper implements LifeCycle {

    private String servletName;

    private String urlPattern;

    private String servletClass;

    private HttpServlet servlet;

    public HttpServlet getServlet() {
        return servlet;
    }

    public void setServlet(HttpServlet servlet) {
        this.servlet = servlet;
    }

    private URLClassLoader classLoader;

    public URLClassLoader getClassLoader() {
        return classLoader;
    }

    public void setClassLoader(URLClassLoader classLoader) {
        this.classLoader = classLoader;
    }

    public String getServletName() {
        return servletName;
    }

    public void setServletName(String servletName) {
        this.servletName = servletName;
    }

    public String getUrlPattern() {
        return urlPattern;
    }

    public void setUrlPattern(String urlPattern) {
        this.urlPattern = urlPattern;
    }

    public String getServletClass() {
        return servletClass;
    }

    public void setServletClass(String servletClass) {
        this.servletClass = servletClass;
    }

    @Override
    public void init() throws Exception {
        Class<?> clazz = classLoader.loadClass(servletClass);
        servlet = (HttpServlet) clazz.newInstance();
    }

    @Override
    public void start() throws Exception {

    }
}
